package com.ruoyi.business.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.business.Buy;
import com.ruoyi.business.MyPage;
import com.ruoyi.business.PageConfig;
import com.ruoyi.business.mapper.BuyMapper;
import com.ruoyi.business.qo.BuyListQO;
import com.ruoyi.business.vo.BuyVO;
import com.ruoyi.common.common.ResultBody;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * @title: UserService
 * @copyright: copyright (c) 2021
 * @author: jiangguanjun
 * @date: 2023/2/8 12:55
 * @firstReview:
 * @lastReview:
 * @desc: 用户相关
 */
@Slf4j
@Component
public class BuyService extends ServiceImpl<BuyMapper, Buy> {

    @Autowired
    private BuyMapper buyMapper ;


    public ResultBody<IPage<BuyVO>> queryPage(BuyListQO buyListQO) {
        MyPage myPage = PageConfig.getPage() ;

        Page<BuyVO> page = new Page<>(myPage.getPageNum(),myPage.getPageSize()) ;
        IPage<BuyVO> iPage = buyMapper.selectByPage(page,buyListQO) ;

        return ResultBody.success(iPage) ;

    }

    public Integer deleteById(Integer id) {
        int res = buyMapper.deleteById(id) ;
        return res ;
    }
}
